<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网生活管理后台</title>
  <?php include("common/conn.php"); if($_SESSION['shopid']==""){echo "<script>window.location.href='login.php';</script>";} 

  if($_GET['del']=="ok")
  {
    $area = array(); 
    $area= $_POST['checkbox'];

    foreach ($area as $k=>$v)
    {
      $srat1=mysql_query("DELETE FROM goods where goodsid='".$v."'");
    }

  }


  if($_GET['ad']!="")
  {    

    $srat1=mysql_query("update goods set ad='".$_REQUEST['ad']."' where goodsid='".$_REQUEST['id']."'");

    if($_GET['ad']!="0")
    { 
      echo "<script>window.location.href='addad.php?goodsid=$_REQUEST[id]&id=$_REQUEST[gid]';</script>";
    }


  }



  if($_GET['tejia']!="")
  {    

    $srat1=mysql_query("update goods set tejia='".$_REQUEST['tejia']."' where goodsid='".$_REQUEST['id']."'");

  }
  if($_GET['xihuans']!="")
  {    

    $srat1=mysql_query("update goods set xihuan='".$_REQUEST['xihuans']."' where goodsid='".$_REQUEST['id']."'");

  }



  ?>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />
  <script type="text/JavaScript">
    <!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->
  <div id="sub_nav">
    <div id="subnav_wrap" class="container_12">
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="goods2.php">商品管理</a></li>
          <li><a href="xihuan.php" class="sub_nav_active" >喜欢管理</a></li>
        </ul>
      </div>

    </div>


  </div>
  <div class="container_12">
    <form action="?" method="post">
      <label>社区</label>
      <select name="classify" class="select" onchange="MM_jumpMenu('parent',this,0)">
        <?php if (!isset($_GET[cityid]) ) {?>
        <option value="?path=<?php echo $_GET[path]; ?>">全部社区</option>
        <?php }?>
        <?php if($_GET[cityid]!=""){?>
        <option value="?path=<?php echo $_GET[path]; ?>">全部社区</option>
        <?php }else{?>
        <?php } $rert32=mysql_query("select * from city order by id desc ");
        while($sdg32=mysql_fetch_array($rert32)){
          $query=mysql_query("select * from shop where shopid='".$_GET[shopid]."'");
          $result=mysql_fetch_array($query);
          ?>                  
          <option  value="?city=<?php echo $sdg32[city];?>&cityid=<?php echo $sdg32[id];?>" <?php if ($sdg32[id]==$_REQUEST[cityid]) { ?>selected<?php } ?>><?php echo $sdg32[city];?></option>
          <?php }?>

        </select>

        <label>商家</label>
        <select name="classify" class="select" onchange="MM_jumpMenu('parent',this,0)">
          <?php if (!isset($_GET[shopid])) {?>
          <option value="?path=<?php echo $_GET[path]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">全部商家</option>
          <?php }?>
          <?php if($_GET[shop]!=""){?>
          <!-- <option  value="?brand=<?php echo $_GET[shop];?>"> -->
          <option value="?path=<?php echo $_GET[path]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">全部商家</option>
          <?php echo $_GET[shop];?></option>
          <?php }else{?>            
          <?php } 
          $_sql = "select * from shop ";
          if($_GET[cityid]!=""){
            $_sql.=" where city=$_GET[cityid]";
          }
          $_sql.=" order by shopid desc ";
          $rert32=mysql_query($_sql);
          while($sdg32=mysql_fetch_array($rert32)){?>
          <option <?php if ($sdg32[shopid]==$_REQUEST[shopid]) { ?>selected<?php } ?> value="?cityid=<?php echo $_REQUEST[cityid]; ?>&shopid=<?php echo $sdg32[shopid];?>&shop=<?php echo $sdg32[name];?>"><?php echo $sdg32[name];?></option>
          <?php }?>

        </select>
        <input  type="text" class="text" placeholder="搜索商品关键字"  name="keywords"/>
        <input name="" type="submit" value="搜索商品" class="submit"/>
      </form>
    </div>
    <form action="?del=ok" method="post"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">



        <tr>

          <th width="2%" scope="col">
            <input type="checkbox" name="checkbox" id="checkbox" class="checkall" /><label for="checkbox"></label></th>
            <th width="10%" scope="col">营销</th>
            <th width="10%" scope="col">小区</th>
            <th width="10%" scope="col">商家</th>
            <th width="3%" scope="col">点赞</th>
            <th width="10%" scope="col">图	</th>
            <th width="15%" scope="col">标题</th>
            <th width="10%" scope="col">分类</th>
            <th width="10%" scope="col">出售价格</th>
            <th width="5%" scope="col">销量</th>
            <th width="15%" scope="col">操作</th>
          </tr>

          <?php 
          mysql_query('SET NAMES UTF8');  

          $ren="1";
          $sex="0";
$perNumber=20; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
if($_REQUEST[keywords]!="")
{
  $count=mysql_query("select count(*) from goods where shopid=".$_SESSION[shopid]." and title like '%".$_REQUEST[keywords]."%' and  xihuan='".$ren."'");

}
else if($_REQUEST[shopid]!=""){

  $count=mysql_query("select count(*) from goods where shopid = '".$_REQUEST[shopid]."'and  xihuan='".$ren."'");

}

else if($_REQUEST[cityid]!=""){
  $count=mysql_query("select count(*) from goods where shopid in (select shopid from shop where city='".$_REQUEST[cityid]."') and  xihuan='".$ren."'");


}

else
{
  $count=mysql_query("select count(*) from goods where shopid=".$_SESSION[shopid]." and xihuan='".$ren."'");
}

//获得记录总数
$rs=mysql_fetch_array($count); 
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数

if (!isset($page)) {
  $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的

if($_REQUEST[keywords]!="")
{
  $rert30=mysql_query("select * from goods where shopid=".$_SESSION[shopid]." and title like '%".$_REQUEST[keywords]."%' and  xihuan='".$ren."' order by goodsid desc limit $startCount,$perNumber");
}	


else if($_REQUEST[shopid]!=""){

  $rert30=mysql_query("select * from goods where  shopid = '".$_REQUEST[shopid]."'and  xihuan='".$ren."'  order by goodsid desc limit $startCount,$perNumber");

}

else if($_REQUEST[cityid]!=""){
  $rert30=mysql_query("select * from goods where  shopid in (select shopid from shop where city='".$_REQUEST[cityid]."') and  xihuan='".$ren."'  order by goodsid desc limit $startCount,$perNumber");	


}

else {
  $rert30=mysql_query("select * from goods  where shopid=".$_SESSION[shopid]." and xihuan='".$ren."' order by goodsid  desc limit $startCount,$perNumber");
}				


while($sdg30=mysql_fetch_array($rert30)){


  $rert35=mysql_query("select * from shop where shopid='".$sdg30[shopid]."'");
  $sdg35=mysql_fetch_array($rert35);



  $ime=$sdg30[images];
  $de = array();
  $de=explode("," ,$ime);
  $images=$de[0];
  ?>

  <tr>

    <td scope="col"><input type="checkbox" name="checkbox[]" id="checkbox"  value="<?php echo $sdg30[goodsid];?>"/></td>
    <td scope="col">
      <?php if($sdg30[xihuan]==1){?><div class="youse2"><a href="?xihuans=0&id=<?php echo $sdg30[goodsid];?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">取消喜欢</a></div><?php }else{?><div class="youse2"><a href="?xihuans=1&id=<?php echo $sdg30[goodsid];?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">猜你喜欢</a></div><?php }?>
    </td>
    <?php
    $query = mysql_query("select * from city where id = ".$sdg35[city]);
    $city = mysql_fetch_assoc($query); 
    ?>
    <td scope="col"><?php echo $city[city];?><?php echo $sdg35[quyu];?></td>
    <td scope="col"><?php echo $sdg35[name];?></td>
    <td scope="col"><?php echo $sdg30[xihuan];?></td>
    <td scope="col"><img src="<?php echo $images;?>" height="50" width="50"/></td>
    <td scope="col"><?php echo $sdg30[title];?></td>
    <td scope="col"><?php echo $sdg30[xilie];?><?php echo $sdg30[zixilie];?></td>
    <td scope="col"><?php echo $sdg30[price];?></td>
    <td scope="col"><?php echo $sdg30[xiaoliang];?></td>
    <td scope="col"><div class="youse"><a href="addgoods.php?gid=<?php echo $sdg30[goodsid];?>&keywords=<?php echo $_REQUEST[keywords]; ?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>&id=<?php echo $_REQUEST[id]; ?>">编辑商品</a></div><div class="youse2"><a href="addgoodsimg.php?id=<?php echo $sdg30[goodsid];?>">商品图库</a></div>
    </td>
  </tr>


  <?php }?>
</table>
<div class="grid_12">

  <div class="clearfix"><input name="" type="submit" value="删除选中" class="submit"  /></div>

  <ul id="pagination">



    <?php  

    if ($page > 1) { //上一页 ?>
    <li><a     href="?page=1&keywords=<?php echo $_REQUEST[keywords]; ?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">首页</a></li>
    <li><a     href="?page=<?php echo ($page-1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">上一页</a></li>
    <?php }

    ?>

    <li class="active"><?php echo $page;?></li>

    <?php



    if ($_GET[page]!=$totalPage) { //下一页 ?>
    <li><a     href="?page=<?php echo ($page+1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">下一页</a></li>
    <?php }

    if ($totalPage>1) { //下一页 ?>
    <li><a     href="?page=<?php echo $totalPage; ?>&keywords=<?php echo $_REQUEST[keywords]; ?>&shopid=<?php echo $_REQUEST[shopid]; ?>&shop=<?php echo $_REQUEST[shop]; ?>&cityid=<?php echo $_REQUEST[cityid]; ?>">尾页</a></li>

    <?php }?>


  </ul>

</div>           
</div>
</form>
</body>
</html>
